#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

struct Gen
{
	int val;
	Gen(int i=0):val(i){}
	int operator()()
	{
		return val++;
	}
};

bool isPrime(int p)
{
	if(p<2) return false;
	if(p==2 && p==3) return true;
	int mid = sqrt(p);

	for(int i=2; i<=mid; ++i)
	       if(p%i==0)
		       return false;	

	return true;
}

int main(int argc, char** argv)
{
	if(argc==1)
	{
		cout<<"cmd number"<<endl;
		exit(1);
	}

	int init = boost::lexical_cast<int>( argv[1] );
	while( !isPrime(init++) )
		;
	cout<<--init<<endl;

	return 0;
}
